﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<ImbaTracker.Models.Issue>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Issues
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2>Issues</h2>

    <table>
        <tr>
            <th></th>
            <th> Id </th>
            <th> Project </th>
            <th> Brief </th>
            <th> Status </th>
            <th> Implementer </th>
            <th> Priority </th>
            <th> Preferred End Date </th>
            <th> Parent Problem </th>
        </tr>
    <% var db = new ImbaTracker.Models.ImbaDBEntities(); %>
    <% foreach (var item in Model) { %>
        <tr>
            <td>
                <% if (ImbaTracker.Content.Helper.canProjectAccess(User)
                       || item.Implementer.Login == User.Identity.Name
                       || item.Assigner.Login == User.Identity.Name) { %>
                <%:     Html.ActionLink("Edit", "Edit", new { id = item.Id })%> |
                <% } %>
                <%: Html.ActionLink("Details", "Details", new { id=item.Id })%>
               
            </td>
            <td>
                <%: item.Id %>
            </td>
            <td>
                <%: item.Project.Name %>
            </td>
            <td>
                <%: item.Brief %>
            </td>
            <td>
                <%: ImbaTracker.Content.Helper.getStatus(item.StatusId).Name%>
            </td>
            <td>
                <%: item.Implementer.Login %>
            </td>
            <td>
                <%: item.Priority %>
            </td>
            <td>
                <%: String.Format("{0:g}", item.PreferredEndDate).Replace(" 0:00", "") %>
            </td>
            <td>
                <%: (from i in db.Issues
                    where i.Id == item.ParentId select i).Count() > 0
                    ?
                        (from i in db.Issues
                        where i.Id == item.ParentId select i).Single().Id
                        + ". "
                        + (from i in db.Issues
                        where i.Id == item.ParentId select i).Single().Brief
                    : ""
                %>
            </td>
        </tr>
    
    <% } %>

    </table>

</asp:Content>

